package com.cloud.rou.im.client.context;

import com.cloud.rou.im.client.handler.GlobalHandler;
import com.cloud.rou.im.msg.Msg;
import io.netty.channel.ChannelHandlerContext;

/**
 * <p></p>
 *
 * @author GaoShuangWen
 */
public class UserContextHolder {
    static UserContext userContext = new UserContext();

    private UserContextHolder() {

    }

    public static UserContext context() {
        return UserContextHolder.userContext;
    }
    public static void addContext(UserContext userContext) {
        UserContextHolder.userContext = userContext;
    }

    public static void writeAndFlush(Msg msg) {
        GlobalHandler handler = UserContextHolder.context().getHandler();
        handler.writeAndFlush(msg);
    }


}
